var fs = require('fs')
var path = require('path')

//两个文件名

let fileName1 = path.resolve(__dirname, 'data.txt')
let fileName2 = path.resolve(__dirname, 'data-bak.txt')

//读取文件的stream流对象
var readStream = fs.createReadStream(fileName1)
var writeStream = fs.createWriteStream(fileName2)

//执行拷贝，通过pipe
readStream.pipe(writeStream)
readStream.on('end', () => {
    console.log('完成');
})